a=0.1;
b=5;

n=5;

tempfun0=@(x)x.^0.5-0.1*x;
tempfun1=@(x)0.5*x.^(-0.5)-0.1;
tempfun2=@(x)-0.25*x.^(-1.5);
xx      =   chebnode(n,a,b);
XB      =   chebbas(n,a,b,xx,[0;1;2]);
XBB     =   XB{1};
x       =   linspace(a,b,20)';
yy0     =   tempfun0(xx);
yy1     =   tempfun1(xx([1;end]));
y0      =   tempfun0(x);
y1      =   tempfun1(x);
y2      =   tempfun2(x);

Coef=   XBB\yy0;
yy1=XB{2}*Coef;
yy2=XB{3}*Coef;

figure;
subplot(1,3,1)
plot(x,y0,'k-');
hold on;
plot(xx,yy0,'ro');
subplot(1,3,2)
plot(x,y1,'k-');
hold on;
plot(xx,yy1,'ro');
subplot(1,3,3)
plot(x,y2,'k-');
hold on;
plot(xx,yy2,'ro');

